package procsim;

import java.awt.*;

public class PaintMaskedInterrupts extends PaintTab{
    public PaintMaskedInterrupts(Paint parent){
        super(parent);
        //Coordinates
        Design.IMR1.addCoords(this, 40, 40, 75, 40).addCoords(this, Design.MILeft.getLower2Coords(30));
        Design.IMR2.addCoords(this, 115, 40, 150, 40).addCoords(this, Design.MIMiddle.getLower2Coords(30));
        Design.IMR3.addCoords(this, 190, 40, 225, 40).addCoords(this, Design.MIRight.getLower2Coords(30));
        Design.PRPER1.addCoords(this, Design.MILeft.getUpper2Coords(55));
        Design.PRPER2.addCoords(this, Design.MIMiddle.getUpper2Coords(55));
        Design.PRPER3.addCoords(this, Design.MIRight.getUpper2Coords(55));
        Design.one.addCoords(this, 120, 180, 120, 200);
        Design.MILeftResult.addCoords(this, Design.MILeft.getResCoords(50)).addCoords(this, 82, 150, 150, 150).addCoords(this, 150, 150, 150, 200);
        Design.MIMiddleResult.addCoords(this, Design.MIMiddle.getResCoords(40)).addCoords(this, 157, 140, 180, 140).addCoords(this, 180, 140, 180, 200);
        Design.MIRightResult.addCoords(this, Design.MIRight.getResCoords(40)).addCoords(this, 232, 140, 210, 140).addCoords(this, 210, 140, 210, 200);
        Design.MILeftResult.addCoords(this, 150, 178, 255, 178).addCoords(this, Design.MIOr.getLower3Coords(40));
        Design.MIMiddleResult.addCoords(this, 180, 162, 255, 162).addCoords(this, Design.MIOr.getMiddle3Coords(40));
        Design.MIRightResult.addCoords(this, 210, 147, 255, 147).addCoords(this, Design.MIOr.getUpper3Coords(40));
        Design.MIOrResult.addCoords(this, Design.MIFarRight.getMiddle3Coords(48));
        Design.PSWI.addCoords(this, Design.MIFarRight.getUpper3Coords(40));

        Design.PRPER.addCoords(this, Design.MIFarRight.getResCoords(40));

        Design.MIComparatorG.addCoords(this, Design.MIComparator.getGreaterCoords(20)).addCoords(this, 125, 480, 330, 480).addCoords(this, 330, 480, 330, 178).addCoords(this, Design.MIFarRight.getLower3Coords(40));

        Design.prL0.addCoords(this, 60, 335, 148, 335).addCoords(this, 142, 335, 142, 370).addCoords(this, 148, 300, 148, 335);
        Design.prL1.addCoords(this, 60, 355, 183, 355).addCoords(this, 109, 355, 109, 370).addCoords(this, 183, 300, 183, 355);

        Design.PSWL1.addCoords(this, 189, 335, 189, 370);
        Design.PSWL0.addCoords(this, 222, 355, 222, 370);

        Design.MIA.addCoords(this, Design.MIComparator.getInACoords(28));
        Design.MIB.addCoords(this, Design.MIComparator.getInBCoords(28));

        Design.MIComparatorE.addCoords(this, Design.MIComparator.getEqualCoords(10));
        Design.MIComparatorL.addCoords(this, Design.MIComparator.getLessCoords(10));
        
        //Collections
        elements.add(Design.MILeft);
        elements.add(Design.MIMiddle);
        elements.add(Design.MIRight);
        elements.add(Design.MIFarRight);
        elements.add(Design.MIOr);
        elements.add(Design.MIComparator);
        elements.add(Design.MICoder);

        lines.add(Design.PSWI);
        lines.add(Design.PSWL0);
        lines.add(Design.PSWL1);
        lines.add(Design.prL1);
        lines.add(Design.prL0);
        lines.add(Design.IMR1);
        lines.add(Design.IMR2);
        lines.add(Design.IMR3);
        lines.add(Design.PRPER1);
        lines.add(Design.PRPER2);
        lines.add(Design.PRPER3);
        lines.add(Design.PRPER);
        lines.add(Design.MIA);
        lines.add(Design.MIB);
        lines.add(Design.one);
        lines.add(Design.MILeftResult);
        lines.add(Design.MIMiddleResult);
        lines.add(Design.MIRightResult);
        lines.add(Design.MIFarRightResult);
        lines.add(Design.MIOrResult);
        lines.add(Design.MIComparatorG);
        lines.add(Design.MIComparatorL);
        lines.add(Design.MIComparatorE);
        lines.add(Design.MICoderOut);
    }
    @Override
    public void paint(Graphics g){
        super.paint(g);
        Graphics2D gnew = (Graphics2D)g;
        Util.saveGraphics(gnew);
        gnew.setColor(Color.GRAY);
        gnew.setStroke(new BasicStroke(2));

        // grouping signals
        gnew.drawLine(99, 368, 99, 370); // |
        gnew.drawLine(99, 370, 123, 370); // -
        gnew.drawLine(123, 370, 125, 372); // /
        gnew.drawLine(125, 372, 127, 370); // \
        gnew.drawLine(127, 370, 151, 370); // -
        gnew.drawLine(151, 370, 151, 368); // |

        // grouping signals
        gnew.drawLine(179, 368, 179, 370); // |
        gnew.drawLine(179, 370, 203, 370); // -
        gnew.drawLine(203, 370, 205, 372); // /
        gnew.drawLine(205, 372, 207, 370); // \
        gnew.drawLine(207, 370, 231, 370); // -
        gnew.drawLine(231, 370, 231, 368); // |

        Util.restoreGraphics(gnew);
    }
}
